def calculator(num1, op, num2):
    if op == '+':
        return num1 + num2
    elif op == '-':
        return num1 - num2
    elif op == '*':
        return num1 * num2
    elif op == '/':
        if num2 == 0:
            return "error"
        else:
            return num1 / num2
    else:
        return "invalid operator"
def main():
    while True:
        try:
            num1 =float(input("input num1:"))
            op = input("enter operator(+ - * /):")
            num2 =float(input("input num2:"))
            result = calculator(num1,op,num2)
            print("result:",result)
            continue_input = input("是否继续？（y/n）")
            if continue_input != 'y':
                break
        except ValueError:
            print("error:invalid input1")
if __name__ == "__main__":
    main()